package com.learn.springboot3.controller;


import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * @author jiang
 */
@RestController
@RequestMapping("hylog")
public class HyLogController {

    @Autowired
    private StringRedisTemplate redisTemplate;



    @RequestMapping("test")
    public String test(){
        String[] s = new String[1000];

        String key = RandomUtil.randomString(6);

        for (int i = 0; i < 10000000; i++) {

           int index = i%1000;
            s[index] = "key_"+i;

            if (index == 999){
                redisTemplate.opsForHyperLogLog().add("test", s);
            }
        }


        return "ok";
    }
}
